<?php
// .-----------------------------------------------------------------------------------
// | WE TRY THE BEST WAY 杭州博也网络科技有限公司
// |-----------------------------------------------------------------------------------
// | Author: 青 <99701759@qq.com>
// | Copyright (c) 2013-2016, http://www.itboye.com. All Rights Reserved.
// |-----------------------------------------------------------------------------------
// 微信用户表中的信息在$this->userinfo
// 用户newmember表的信息在$this->newmember中
// 用户角色表的信息在$this->role中
namespace app\web\controller;

use app\src\post\logic\VPostInfoLogic;
use app\src\post\logic\PostLogic;
use app\src\system\logic\DatatreeLogicV2;

class Story extends Base
{


    /*
     * 首页
     * */
    public function djstory()
    {

        return $this->fetch();
    }

    public function zyzstory()
    {

        return $this->fetch();
    }

    public function xmhd(){

        $parent='6269';

        $map['parents'] = array('like','%'.$parent.',%');
        $result=(new DatatreeLogicV2())->queryNoPaging($map);
        $list = \app\src\admin\helper\MenuHelper::list_to_tree($result,'id','parentid','_child',$parent);
        // dump($list);exit;

        $this->assign('list',$list);

        //  dump('aa');
        return $this->fetch();
    }

    public function data()
    {

        $params = array();
        $map = array();
        $page = array('curpage' => $this->_param('p', 0), 'size' => 5);
        $order = "start_time desc ";
        $map['post_category'] = $this->_param('type');
        //     dump($map);
        $result = (new PostLogic())->queryCacheWithPagingHtml($map, $page, $order, $params);
//dump($result);

        $data=array();
        if ($result['status']&&!empty($result['info']['list'])) {
            foreach ($result['info']['list'] as $k => $v) {

                $data[$k]['id'] = $v['id'];
                $data[$k]['title'] = $v['post_title'];
                $data[$k]['main_img'] = $v['main_img'];
                $data[$k]['start_time'] = date('Y-m-d H:i', $v['start_time']);
            }

            $data = json_encode($data);
            echo $data;
        }else{
            $data = json_encode($data);
            echo $data;
        }

    }


    /*
     * 文章详情
     * */
    public function detail()
    {

        $id = $this->_param('id');
        //  $order='itboye_product.create_time desc';
        $result = (new PostLogic())->getCacheInfo(['id' => $id]);
        $detail = $result['info']['post_content'];

     //   $this->assign('act_id', 6);
        $this->assign('detail', $detail);

        return $this->fetch();
    }



    public function ajaxReturn($data)
    {
        //不做处理
    }


}